#!/bin/sh
# Run each test and compare against known good output

if [ ! -f ../comp ]
then
    echo "Need to build ../comp first"
    exit 1
fi

for i in input*
do
    if [ ! -f "out.$i" ]
    then
        echo "Can't run test on $i, no output file!"
    else
        echo -n $i
        ../comp $i
        cc -o out out.s
        ./out > trail.$i
        cmp -s "out.$i" "trail.$i"
        if [ "$?" -eq "1" ]
        then
            echo ": failed"
            diff -c "out.$i" "trail.$i"
            echo
        else
            echo ": OK"
        fi
        rm out out.s "trail.$i"
    fi
done
